package com.yklx.youke.admin.service.impl;

import com.yklx.youke.admin.mapper.RoleMapper;
import com.yklx.youke.admin.service.RoleService;
import com.yklx.youke.entity.Role;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {

    private final RoleMapper roleMapper;

    public RoleServiceImpl(RoleMapper roleMapper) {
        this.roleMapper = roleMapper;
    }

    @Override
    public List<Role> getAllRoles() {
        return roleMapper.getAllRoles();
    }

    @Override
    public Role getRoleById(String roleId) {
        return roleMapper.getRoleById(roleId);
    }

    @Override
    public boolean createRole(Role role) {
        return roleMapper.insertRole(role) > 0;
    }

    @Override
    public boolean updateRole(Role role) {
        return roleMapper.updateRole(role) > 0;
    }

    @Override
    public boolean deleteRole(String roleId) {
        return roleMapper.deleteRole(roleId) > 0;
    }
}